<template>
  <div>
    <!-- <router-view :key="$route.fullPath" /> -->
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive" />
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive" />
  </div>
</template>

<script>
import axios from "axios";
export default {
  methods: {
    //做一个防抖
    debounce(fn, wait) {
      let timer = null;
      return function() {
        if (timer !== null) {
          clearTimeout(timer);
        }
        timer = setTimeout(fn, wait);
      };
    },
    //检测设备
    isMoble() {
      let flag = navigator.userAgent.match(
        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
      );
      return flag;
    },
    changeSize() {
      this.getRem(1920, 100);
    },
  },
  mounted() {
    window.addEventListener("resize", this.debounce(this.changeSize, 1000));
    if (this.isMoble()) {
      this.$router.replace("/phone");
    }
  },
};
</script>
